import request from '@/utils/request'
import type { 
  ApiResponse, 
  LoginRequest, 
  LoginResponse, 
  RegisterRequest, 
  UserInfo 
} from '@/types'

// 认证相关API
export const authApi = {
  // 用户登录
  login: (data: LoginRequest): Promise<ApiResponse<LoginResponse>> => {
    return request.post('/auth/login', data)
  },

  // 用户注册
  register: (data: RegisterRequest): Promise<ApiResponse<UserInfo>> => {
    return request.post('/auth/register', data)
  },

  // 用户登出
  logout: (): Promise<ApiResponse<string>> => {
    return request.post('/auth/logout')
  },

  // 检查登录状态
  isLogin: (): Promise<ApiResponse<string>> => {
    return request.get('/auth/isLogin')
  },

  // 获取当前用户信息
  getProfile: (): Promise<ApiResponse<UserInfo>> => {
    return request.get('/auth/profile')
  }
}